









package com.company.z2mingling.zerenlian;

import java.util.ArrayList;
import java.util.HashSet;

/**
 * @author cbf4Life cbf4life@126.com
 * I'm glad to share my knowledge with you all.
 * �����ַ�������
 */
public class CommandVO {
	
	public final static String DIVIDE_FLAG =" ";
	
	
	public final static String PREFIX="-";
	
	
	private String commandName = "";
	
	private ArrayList<String> paramList = new ArrayList<String>();
	
	
	private ArrayList<String> dataList = new ArrayList<String>();
	
	
	public CommandVO(String commandStr){
		
		if(commandStr != null && commandStr.length() !=0){		
			
			String[] complexStr = commandStr.split(CommandVO.DIVIDE_FLAG);
			
			this.commandName = complexStr[0];
			
			for(int i=1;i<complexStr.length;i++){
				String str = complexStr[i];
				
				if(str.indexOf(CommandVO.PREFIX)==0){
					this.paramList.add(str.replace(CommandVO.PREFIX, "").trim());
				}else{
					this.dataList.add(str.trim());
				}
			}
		}else{
			
			System.out.println("�������ʧ�ܣ����봫��һ���������ִ�У�");
		}
	}
	
	
	public String getCommandName(){
		return this.commandName;
	}
	
	
	public ArrayList<String> getParam(){
		
		if(this.paramList.size() ==0){
			this.paramList.add("");
		}		
		return new ArrayList(new HashSet(this.paramList));
	}
	
	
	public ArrayList<String> getData(){
		return this.dataList;
	}
	
	
	public String formatData(){
		
		if(this.dataList.size() ==0){
			return "";
		}else{
			return this.dataList.toString();
		}
	}
	
	public static void main(String[] args) {
		
		String str = "ls";
		CommandVO vo = new CommandVO(str);
		System.out.println("������Ϊ��"+vo.getCommandName());
		System.out.println("������Ϊ��"+vo.getParam());
		System.out.println("������Ϊ��"+vo.getData());
		System.out.println(vo.getParam().contains(""));
	}
}